<%@page import="java.net.URLEncoder"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>查看地图</title>
<style type="text/css">
body,html,#allmap {
	width: 100%;
	height: 100%;
	overflow: hidden;
	margin: 0;
}

</style>
<script type="text/javascript"
	src="http://api.map.baidu.com/api?v=1.5&ak=FD619b3a912624d6d79233bbf0709528"></script>
<script type="text/javascript" src="js/DistanceTool_min.js"></script>
<script type="text/javascript" src="js/jquery.PrintArea.js"></script>
<link rel="stylesheet" type="text/css" href="css/PrintArea.css">
<script type="text/javascript" src="js/SearchInfoWindow_min.js"></script>
<link rel="stylesheet" type="text/css"
	href="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css">
<script type="text/javascript">
    	var viewType='${viewType}';
    	var type='${type}';
    	var ltype='${ltype}';
    	var point;
    	var map;
    	var content="${content}";
    	var area; 
    	var markname='${markerName}';
    	var icon=new BMap.Icon('images/marker/'+markname,new BMap.Size(36, 36),
    		 { anchor: new BMap.Size(18, 18)});
		$(document).ready(function(e) {
            map = new BMap.Map("allmap");            // 创建Map实例
			map.enableScrollWheelZoom();  //启用滚轮放大缩小
			map.enableContinuousZoom();    // 开启连续缩放效果
			map.enableInertialDragging();// 开启惯性拖拽效果
			map.addControl(new BMap.NavigationControl());     
            map.addControl(new BMap.ScaleControl());
			
			if(viewType=='loc'){//定位
				var lng=content.split("*")[0];
        		var lat=content.split("*")[1];
        		var title=content.split("*")[2];
        		var landType=content.split("*")[3];
        		var strPoints=content.split("*")[4];
        		var stype=content.split("*")[5];
        		var context='<div style="margin:0;line-height:20px;padding:2px;">'+
						content.split("*")[6]+'</div>';
            	if(type=='1'){ //市区统计
					height=250;
            	}else if(type=='2'){ //行政区统计
            		height=150;
            	}else if(type=='3'){ //土地相关
					if(ltype=='1'){
						height=150;
					}else if(ltype=='2'){
						height=170;
					}else{
						height=200;
					}
            	}
            	point = new BMap.Point(parseFloat(lng),parseFloat(lat));
        		var opts = {
			  		width : 300,     // 信息窗口宽度
			  		height: height,     // 信息窗口高度
			  		title : title,  // 信息窗口标题
			  		panel  : "panel",         //检索结果面板
  					enableAutoPan : true,     //自动平移
  					searchTypes   :[
  						BMAPLIB_TAB_SEARCH,   //周边检索
  						BMAPLIB_TAB_TO_HERE,  //到这里去
  						BMAPLIB_TAB_FROM_HERE //从这里出发
  					]
				} ;
				var marker;
				var searchInfoWindow = new BMapLib.SearchInfoWindow(map,context,opts);
				if(landType==1){
					marker = new BMap.Marker(point,{icon:icon});
					marker.addEventListener("click",function(){
    					searchInfoWindow.open(marker);
    				});
				}else{
					var points=strPoints.split("|");
					var pts=[];
					for(var j=0;j<points.length;j++){
						var str=points[j].split(",");
						var pt=new BMap.Point(str[0],str[1]);
						pts.push(pt);
					}
					marker=new BMap.Polygon(pts,{strokeColor:"blue",fillColor:"red", strokeWeight:2, strokeOpacity:0.2});
					marker.addEventListener("click",function(){
    					searchInfoWindow.open(new BMap.Point(lng, lat));
    				});
				}
    			map.addOverlay(marker);	
    			map.centerAndZoom(point,16);
            }else{
            	map.centerAndZoom('${ecity.name}');
            }
        });
	</script>
</head>
<body>
	<div id="allmap"></div>
</body>
</html>
